#pragma once

#include <fstream>
#include <string>
#include <list>

class TextLog {
protected:
	std::list<std::string> m_lines;
	unsigned int m_maxLines;
	int m_currentLine;
	bool m_bottomToTop;
	float m_height;
	int getMaxDrawableLines() const;
public:
	TextLog(float height, bool bottomToTop = true, unsigned int maxLines = 9999);
	~TextLog();
	void addLine(std::string line);
	void setCurrentLine(int line);
	int getCurrentLine() const;
	std::list<std::string>::const_iterator getLine(int i) const;
	void addBlankLine();
	bool bottomToTop() const;
	void resetCurrentLine();
	void shift(bool up);
	void page(bool up);
	int getNumLines() const;
	void save(std::ofstream& file) const;
	void load(std::ifstream& file);
};

inline int TextLog::getCurrentLine() const {return m_currentLine;}
inline bool TextLog::bottomToTop() const {return m_bottomToTop;}
inline void TextLog::resetCurrentLine() {m_currentLine = 0;}
inline int TextLog::getNumLines() const {return m_lines.size();}
inline void TextLog::addBlankLine() {m_lines.push_back("");}